#pragma once

#include "common_data.h"
#include "broker.h"

#include <mavsdk/mavsdk.h>
#include <mavsdk/plugins/info/info.h>
#include <mavsdk/plugins/telemetry/telemetry.h>
#include <mavsdk/plugins/action/action.h>
using namespace mavsdk;

#include <ev.h>
#include <iostream>
#include <chrono>
#include <thread>
#include <string>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <string>

#define FC_ACTION_TIMER_PERIOD 1.0
#define FC_TAKEOFF_TIMER_PERIOD 1.0
#define FC_LAND_TIMER_PERIOD 1.0

typedef struct{
  Action* action;
  Telemetry* telemetry;
}FC_PLUG_t;

typedef struct{
  ev_timer timer;
  FC_PLUG_t plug;
}FC_PLUG_TIMER_t;

void fc_srv_start(std::string channel_name);

void fc_telemetry_init(Telemetry& telemetry);

void fc_ctl_srv_start(Action& action, Telemetry& telemetry);

void fc_takeoff_action(FC_PLUG_t plug);

void fc_land_action(FC_PLUG_t plug);

static void action_timer_cb(struct ev_loop *loop, ev_timer *w, int revents);

static void takeoff_timer_cb(struct ev_loop *loop, ev_timer *w, int revents);

static void land_timer_cb(struct ev_loop *loop, ev_timer *w, int revents);

